/*
 * @Author: zhanglianchang
 * @Date: 2020-08-01 14:39:32
 * @Last Modified by: taoshiwei
 * @Last Modified time: 2019-04-29 14:49:44
 *
 * 题库有关的接口：自己写吧~~  已经被张老师删了 ^_^
 */
import { createAPI } from '@/utils/request'

// 获取列表数据
export const getQuestionsList = params => createAPI('/questions/randoms/', 'get', params)

// 基础题库列表
export const getQuestions = data => createAPI('/questions', 'get', data)

// 基础题库删除
export const delQuestions = id => createAPI(`/questions/${id}`, 'DELETE')

// 学科简单列表
export const getSubjectsSimple = () => createAPI('/subjects/simple', 'get')

// 用户简单列表
export const getUserSimple = () => createAPI('/users/simple')

// 根据id获取题目详情
export const getQuestionsInfo = id => createAPI(`/questions/${id}`)

// 加入或移出精选
export const selected = data => createAPI(`/questions/choice/${data.id}/${data.choiceState}`, 'PATCH', data)

// 删除接口
export const deleteQuestions = (data) => createAPI('/questions/randoms/' + data.id, 'DELETE', data)
//
export const getKindQuestions = (data) => createAPI('/questions/' + data.id, 'GET', data)

// 学科列表
export const getsubject = (data) => createAPI('/subjects/simple', 'get', data)

// 精选题库列表
export const getchoice = data => createAPI('/questions/choice', 'get', data)

// 精选题库上下架
export const changepublish = data => createAPI(`/questions/choice/${data.id}/${data.publishState}`, 'post', data)

// 精选删除
export const delchoice = id => createAPI(`/questions/${id}`, 'DELETE')

// 试题审核
export const choiceCheck = data => createAPI(`/questions/check/${data.id}`, 'post', data)

// 标签列表
export const tags = data => createAPI('/tags', 'get', data)

// 目录列表
export const directorys = data => createAPI('/directorys', 'get', data)

class question {
 // 获取列表数据
 getQuestionsList = params => createAPI('/questions/randoms/', 'get', params)

 // 基础题库列表
 getQuestions = data => createAPI('/questions', 'get', data)

 // 基础题库删除
 delQuestions = id => createAPI(`/questions/${id}`, 'DELETE')

 // 学科简单列表
 getSubjectsSimple = () => createAPI('/subjects/simple', 'get')

 // 用户简单列表
 getUserSimple = () => createAPI('/users/simple')

 // 根据id获取题目详情
 getQuestionsInfo = id => createAPI(`/questions/${id}`)

 // 加入或移出精选
 selected = data => createAPI(`/questions/choice/${data.id}/${data.choiceState}`, 'PATCH', data)

 // 删除接口
 deleteQuestions = (data) => createAPI('/questions/randoms/' + data.id, 'DELETE', data)
 //
 getKindQuestions = (data) => createAPI('/questions/' + data.id, 'GET', data)

 // 学科列表
 getsubject = (data) => createAPI('/subjects/simple', 'get', data)

 // 精选题库列表
 getchoice = data => createAPI('/questions/choice', 'get', data)

 // 精选题库上下架
 changepublish = data => createAPI(`/questions/choice/${data.id}/${data.publishState}`, 'post', data)

 // 精选删除
 delchoice = id => createAPI(`/questions/${id}`, 'DELETE')

 // 试题审核
 choiceCheck = data => createAPI(`/questions/check/${data.id}`, 'post', data)

 // 标签列表
 tags = data => createAPI('/tags', 'get', data)

 // 目录列表
 directorys = data => createAPI('/directorys', 'get', data)
}

// eslint-disable-next-line new-cap
export default new question()
